package ListView_Adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import barcode.code.nhat.iuhbarcode.R;


public class PersonList_Adapter extends BaseAdapter {

    private Context context;
    private ArrayList<Person_Detail> person_details;

    public PersonList_Adapter(Context context, ArrayList<Person_Detail> person_details) {
        this.context = context;
        this.person_details = person_details;
    }

    @Override
    public int getCount() {
        return person_details.size();
    }

    @Override
    public Object getItem(int position) {
        return person_details.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
            convertView = mInflater.inflate(R.layout.list_id_check, null);
        }

        TextView t1, t2, t3, t4;

        t1 = (TextView) convertView.findViewById(R.id.row_id);
        t2 = (TextView) convertView.findViewById(R.id.row_Student);
        t3 = (TextView) convertView.findViewById(R.id.row_Date);
        t4 = (TextView) convertView.findViewById(R.id.row_Period);

        t1.setText(person_details.get(position).getID());
        t2.setText(person_details.get(position).getStudent());
        t3.setText(person_details.get(position).getDate());
        t4.setText(String.valueOf(person_details.get(position).getPer()));

        return convertView;
    }

}
